package com.hyt.it.ogt.kq.common.bm.config.serializable;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.hyt.it.ogt.kq.common.bm.config.JacksonConfig;

import java.io.IOException;
import java.util.Date;

/**
 * @program: it-ogt-bm
 * @description: 日期序列化
 * @author: Yang HuanKun
 * @create: 2022-05-23 15:40
 **/
public class DateSerializer extends JsonSerializer<Date> {
    @Override
    public void serialize(Date value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        String format = DateUtil.format(value, JacksonConfig.DEFAULT_DATE_FORMAT);
        gen.writeString(format);
    }
}
